package waysToBuyPensPencils;

public class Solution {
    public long waysToBuyPensPencils(int total, int cost1, int cost2) {
        //
        int[] pens = new int[total+1]; // pens[i] 表示i元钱可以买钢笔的方案数 pens[i] = i/cost1 + 1.
        for (int i = 0; i <= total; i++) {
            pens[i] = i/cost1 + 1;
        }
        long ans = 0;
        for (int i = 0; i*cost2 <= total; i++) {
            // 买 i只铅笔的方案数
            ans += pens[(total-cost2*i)];
        }
        return ans;
    }
}
